package fragment;

import com.dong.yi18health.R;
import com.squareup.picasso.Picasso;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.ImageView.ScaleType;

public class itemFragment extends Fragment{
	
	News news;
	private TextView tv;
	private ImageView iv;
	public itemFragment(){
//		System.out.println("无参数构造方法");
	};
	
	public void setNews(News news) {
		this.news=news;
		System.out.println("---setnews");
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
//		System.out.println("----oncreate"+news.title);
		View view2 = inflater.inflate(R.layout.news, null);
		tv = (TextView) view2.findViewById(R.id.new_title);
		iv = (ImageView) view2.findViewById(R.id.news_image);
//		System.out.println("-----news.title"+news.title);
//		System.out.println("----------tv"+tv.getText());
		tv.setText(news.title);
		Picasso.with(getActivity()).load("http://www.yi18.net/" + news.img).into(iv);
		iv.setScaleType(ScaleType.FIT_XY);
		return view2;
	}
	
}
